<?php
		$writeHead = "<?php if (!$"."_GET['addNew']) { ?><script type='text/javascript'>$(function() {
		jQuery.fileDelete = function(id,field) {
		$.ajax({
			url: \"ajax.php\",
			data: \"tablename=\"+child_tableName+\"&id=\"+id+\"&field=\"+field+\"&AJAXtask=deleteFile\",
			cache: false,
			complete: function(){
				//alert(\"tablename=\"+child_tableName+\"&id=\"+id+\"&field=\"+field+\"&AJAXtask=deleteFile\");
			}
		});

	};	

	jQuery.deleteAllFiles = function(ID,field) {
		
		$fieldsForDeletionString		
	};		
});
</script>";
	$writeHead .= "<div class='groupItemsContainer'><?php
\n
if ($%id) {
	$%SQLread = \"SELECT * FROM $tableName WHERE $"."parentTable_SQL_where\";
	
$%SQLconnect = mysql_connect(\"$db_host\",\"$db_username\",\"$db_password\");
if (!$%SQLconnect) { echo(\"SQL Connection Error: \" . mysql_error() . \"\\n\");	}\n
else {
	$%SQLexecute = mysql_db_query(\"$db_name\",$%SQLread,$%SQLconnect);
	if (!$%SQLexecute) { echo(\"SQL Execution Error: \" . mysql_error() . \"\\n$%SQL\\n\");	}
	else {
		while($%rowArray = mysql_fetch_array($%SQLexecute,MYSQL_ASSOC)) {
			echo \"<div class='groupItem'>\";
			";
	$writeBody = "\n
			echo \"</div>\";
			}						
		}
	}
	mysql_close($%SQLconnect);
}
}
$%id =\"\";

?>
<div class='groupItem'><?";

$writeBottom = "?>
<div class='saveNewGroupItem'>Save</div>
</div>
</div>
";
	//$writeBody .= print_r($tableArray);
	$writeFooter = " ?>
		<input type=\"hidden\" class='formElement' name=\"id\" value=\"<?php echo $%id;?>\" />
		<div class='saveGroupItem'>SAVE ITEM</div> <div class='deleteGroupItem'>DELETE ITEM</div>
		<?";
	$pageSource = str_replace("%", "", $writeHead) . str_replace("%", "", $fieldVarsString)  .  $inputElementsString . str_replace("%", "", $writeFooter) . str_replace("%", "", $writeBody) . $inputElementsString . str_replace("%", "", $writeBottom);
	//echo str_replace("%", "", $pageSource);
	
	echo "<h2>tableName = $tableName</h2> ";

?>